package dates_numbers_currency;

import java.text.*;
import java.util.*;

public class Numbers {
	public static void main(String[] args) {
		float f1 = 123.4567f;
		Locale locFR = new Locale("fr");	//France
		NumberFormat[] nfa = new NumberFormat[4];
		
		nfa[0] = NumberFormat.getInstance();
		nfa[1] = NumberFormat.getInstance(locFR);
		nfa[2] = NumberFormat.getCurrencyInstance();
		nfa[3] = NumberFormat.getCurrencyInstance(locFR);
		
		for (NumberFormat nf1 : nfa)
			System.out.println(nf1.format(f1));
		

		
		float f2 = 123.45678f;
		NumberFormat nf = NumberFormat.getInstance();
		System.out.println(nf.getMaximumFractionDigits() + " " + nf.getMinimumFractionDigits());
		System.out.println(nf.format(f2) + " ");
		
		nf.setMaximumFractionDigits(5);
		System.out.println(nf.format(f2) + " ");
		
		try {
			System.out.println(nf.parse("1234.567text"));
			nf.setParseIntegerOnly(true);
			System.out.println(nf.parse("1234.567"));
		} catch (ParseException pe) {
			System.out.println("parse exc");
		}
		
		
		
		NumberFormat[] nfa2 = new NumberFormat[2];
		nfa2[0] = NumberFormat.getNumberInstance();
		nfa2[1] = NumberFormat.getCurrencyInstance(locFR);
		for (NumberFormat nf2 : nfa2)
			System.out.println(nf2.format(f1));	
	
	}
}
